//
//  ICViewController.m
//  iComeSDK
//
//  Created by zhangrongwu on 01/16/2018.
//  Copyright (c) 2018 zhangrongwu. All rights reserved.
//

#import "ICViewController.h"
#import "iComeSDK.h"
#import <Masonry/Masonry.h>
#define ALERTSDK(msg)  [[[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:nil \
cancelButtonTitle:@"确定" otherButtonTitles:nil,nil] show]
#define APP_Frame_Height   [[UIScreen mainScreen] bounds].size.height
// 应用程序的屏幕宽度
#define App_Frame_Width    [[UIScreen mainScreen] bounds].size.width
// 提示
@interface ICViewController ()<iComeSDKProtocol>

@end

@implementation ICViewController
- (void)setNavBackgroundColor:(UIColor *)navBackgroundColor {
    UINavigationBar * navBar = self.navigationController.navigationBar;
    [navBar setBackgroundImage:[ICViewController imageWithColor:navBackgroundColor size:CGSizeMake(App_Frame_Width, 1)] forBarMetrics:UIBarMetricsDefault];
    [navBar setBarTintColor:navBackgroundColor];
}




- (void)setNavShadowColor:(UIColor *)navShadowColor {
    UINavigationBar * navBar = self.navigationController.navigationBar;
    [navBar setShadowImage:[ICViewController imageWithColor:navShadowColor size:CGSizeMake(App_Frame_Width, 0.5)]];
}

+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
    if (!color || size.width <= 0 || size.height <= 0) return nil;
    CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
    UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

- (void)unreadCountFirst {
    NSLog(@"asdsdfj;s");
}

- (void)drawLineOfDashByCAShapeLayer:(UIView *)lineView lineLength:(int)lineLength lineSpacing:(int)lineSpacing lineColor:(UIColor *)lineColor lineDirection:(BOOL)isHorizonal {
    
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:lineView.bounds];
    if (isHorizonal) {
        [shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame) / 2, CGRectGetHeight(lineView.frame))];
    } else{
        [shapeLayer setPosition:CGPointMake(CGRectGetWidth(lineView.frame) / 2, CGRectGetHeight(lineView.frame)/2)];
    }
    [shapeLayer setFillColor:[UIColor clearColor].CGColor];
    //  设置虚线颜色为blackColor
    [shapeLayer setStrokeColor:lineColor.CGColor];
    //  设置虚线宽度
    if (isHorizonal) {
        [shapeLayer setLineWidth:CGRectGetHeight(lineView.frame)];
    } else {
        [shapeLayer setLineWidth:CGRectGetWidth(lineView.frame)];
    }
    [shapeLayer setLineJoin:kCALineJoinRound];
    //  设置线宽，线间距
    [shapeLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:lineLength], [NSNumber numberWithInt:lineSpacing], nil]];
    //  设置路径
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, 0, 0);
    if (isHorizonal) {
        CGPathAddLineToPoint(path, NULL,CGRectGetWidth(lineView.frame), 0);
    } else {
        CGPathAddLineToPoint(path, NULL, 0, CGRectGetHeight(lineView.frame));
    }
    
    [shapeLayer setPath:path];
    CGPathRelease(path);
    //  把绘制好的虚线添加上来
    [lineView.layer addSublayer:shapeLayer];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

//    NSString *mail = @"zhangrongwuios@icloud.com";
//    NSString *regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
//    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
//    BOOL isValid = [predicate evaluateWithObject:mail];
    
//    NSString *text = @"// Do any additional setup after loading the view, typically from a nib.";
//    NSRange range  = [text rangeOfString:@"(?:[^,])*\\." options:NSRegularExpressionSearch];
//    if (range.location != NSNotFound) {
//        NSLog(@"%@", [text substringWithRange:range]);
//    }
    
//    NSString *text = @"// Do any additional setup after loading the typically from a nib. view, typically from a nib.";
//    NSError *error = NULL;
//    NSRegularExpression *regx = [NSRegularExpression regularExpressionWithPattern:@"(?:[^,])*\\." options:NSRegularExpressionCaseInsensitive error:&error];
//
//    // 匹配多个
//    NSArray<NSTextCheckingResult *> *results = [regx matchesInString:text options:0 range:NSMakeRange(0, text.length)];
//    [results enumerateObjectsUsingBlock:^(NSTextCheckingResult * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//        NSLog(@"%@", obj);
//        if (obj) {
//            NSLog(@"多次匹配结果 ：%@", [text substringWithRange:obj.range]);
//        }
//    }];
//
//    // 匹配单个
//    NSTextCheckingResult *result = [regx firstMatchInString:text options:0 range:NSMakeRange(0, [text length])];
//    if (result) {
//        NSLog(@"%@", [text substringWithRange:result.range]);
//    }
    
    [self setNavBackgroundColor:[UIColor redColor]];
    [self setNavShadowColor:[UIColor redColor]];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unreadCountFirst) name:@"NotificationReloadDataIMSource" object:nil];

    // 代理必须和初始化im一起执行
    [iComeApiManager instance].delegate = self; // 动态注册cell与tableview点击方法
    
   
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 2)];
    [self drawLineOfDashByCAShapeLayer:lineView lineLength:5 lineSpacing:3 lineColor:[UIColor redColor] lineDirection:YES];
    [self.view addSubview:lineView];
    
    UIButton *btn = [[UIButton alloc] init];
//    btn.frame = CGRectMake(10, 85, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn setTitle:@"注册" forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor darkGrayColor];
    [btn addTarget:self action:@selector(regiseriComeApi) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    UIButton *btn1 = [[UIButton alloc] init];
//    btn1.frame = CGRectMake(10, 140, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn1 setTitle:@"打开消息列表" forState:UIControlStateNormal];
    btn1.backgroundColor = [UIColor darkGrayColor];
    [btn1 addTarget:self action:@selector(openChatList) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn1];
    
    
    UIButton *btn2 = [[UIButton alloc] init];
//    btn2.frame = CGRectMake(10, 195, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn2 setTitle:@"创建群组" forState:UIControlStateNormal];
    btn2.backgroundColor = [UIColor darkGrayColor];
    [btn2 addTarget:self action:@selector(createGroupWithName) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn2];
    
    
    UIButton *btn3 = [[UIButton alloc] init];
//    btn3.frame = CGRectMake(10, 250, [[UIScreen mainScreen] bounds].size.width / 2, 50);
    [btn3 setTitle:@"打开某个聊天" forState:UIControlStateNormal];
    btn3.backgroundColor = [UIColor darkGrayColor];
    [btn3 addTarget:self action:@selector(openChatWindow) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn3];
    
    UIButton *btn31 = [[UIButton alloc] init];
//    btn31.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width / 2, 250, [[UIScreen mainScreen] bounds].size.width / 2, 50);
    [btn31 setTitle:@"打开某个聊天并发送消息" forState:UIControlStateNormal];
    btn31.backgroundColor = [UIColor darkGrayColor];
    [btn31 addTarget:self action:@selector(openChatWindowWithMesssage) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn31];
    
    UIButton *btn4 = [[UIButton alloc] init];
//    btn4.frame = CGRectMake(10, 305, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn4 setTitle:@"分享" forState:UIControlStateNormal];
    btn4.backgroundColor = [UIColor darkGrayColor];
    [btn4 addTarget:self action:@selector(shareToChat) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn4];
    
    
    UIButton *btn5 = [[UIButton alloc] init];
//    btn5.frame = CGRectMake(10, 360, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn5 setTitle:@"获取用户头像" forState:UIControlStateNormal];
    btn5.backgroundColor = [UIColor darkGrayColor];
    [btn5 addTarget:self action:@selector(getEmpPhoto) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn5];
    
    UIButton *btn6 = [[UIButton alloc] init];
//    btn6.frame = CGRectMake(10, 415, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn6 setTitle:@"注销" forState:UIControlStateNormal];
    btn6.backgroundColor = [UIColor darkGrayColor];
    [btn6 addTarget:self action:@selector(destroy) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn6];
    
    
    UIButton *btn7 = [[UIButton alloc] init];
//    btn7.frame = CGRectMake(10, 470, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn7 setTitle:@"打开webview" forState:UIControlStateNormal];
    btn7.backgroundColor = [UIColor darkGrayColor];
    [btn7 addTarget:self action:@selector(openWebView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn7];
    
    UIButton *btn9 = [[UIButton alloc] init];
//    btn9.frame = CGRectMake(10, 525, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn9 setTitle:@"获取最新消息和未读数据" forState:UIControlStateNormal];
    btn9.backgroundColor = [UIColor darkGrayColor];
    [btn9 addTarget:self action:@selector(unreadCount) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn9];
    
    UIButton *btn10 = [[UIButton alloc] init];
//    btn10.frame = CGRectMake(10, 580, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn10 setTitle:@"获取常用联系人" forState:UIControlStateNormal];
    btn10.backgroundColor = [UIColor darkGrayColor];
    [btn10 addTarget:self action:@selector(getRrecentPersion) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn10];
    
    UIButton *btn11 = [[UIButton alloc] init];
//    btn11.frame = CGRectMake(10, 635, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn11 setTitle:@"群组添加联系人，保证群组存在" forState:UIControlStateNormal];
    btn11.backgroundColor = [UIColor darkGrayColor];
    [btn11 addTarget:self action:@selector(appendUsers) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn11];
    
    
    UIButton *btn12 = [[UIButton alloc] init];
//    btn12.frame = CGRectMake(10, 690, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn12 setTitle:@"双人会话" forState:UIControlStateNormal];
    btn12.backgroundColor = [UIColor darkGrayColor];
    [btn12 addTarget:self action:@selector(twoChat) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn12];
    
    UIButton *btn13 = [[UIButton alloc] init];
//    btn13.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width /  2, 85, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn13 setTitle:@"所有群组" forState:UIControlStateNormal];
    btn13.backgroundColor = [UIColor darkGrayColor];
    [btn13 addTarget:self action:@selector(allgroups) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn13];
    
    UIButton *btn14 = [[UIButton alloc] init];
//    btn14.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width /  2, 140, [[UIScreen mainScreen] bounds].size.width /  2, 50);
    [btn14 setTitle:@"群组人员" forState:UIControlStateNormal];
    btn14.backgroundColor = [UIColor darkGrayColor];
    [btn14 addTarget:self action:@selector(groupalluser) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn14];
    
    
    NSMutableArray *list = [[NSMutableArray alloc] initWithObjects:btn,btn1,btn2,btn3,btn31,btn4,btn5,btn6,btn7,btn9,btn10,btn11,btn12,btn13,btn14, nil];
    
//    NSMutableArray *list = [[NSMutableArray alloc] initWithObjects:btn,btn1,btn2,btn3, nil];

    
    // 纵向等间距排列
    [list mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedSpacing:1 leadSpacing:1 tailSpacing:1];
    [list mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
    }];
    
    // 纵向均分，各控件等高度排列
//    [list mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedItemLength:20 leadSpacing:1 tailSpacing:1];
//    [list mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(@15);
//    }];
    
    
    // 横向均分，各控件等间距排列
//    [list mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:1 leadSpacing:10 tailSpacing:10];
//    [list mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(@60);
//        make.height.equalTo(@60);
//    }];
    
    // 横向均分，各控件等宽度排列
//    [list mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:10 leadSpacing:10 tailSpacing:10];
//    [list mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(@60);
//        make.height.equalTo(@60);
//    }];

    
    
  
    
}
- (void)allgroups {
    [[iComeApiManager instance] getGroupsWithgType:2 :^(id result){
        NSLog(@"%@", result);
    } :^(id result) {
        NSLog(@"%@", result);
    }];
}

- (void)groupalluser {
    [[iComeApiManager instance] getUsersWithgId:@"mlt_10000678" :^(id result){
        NSLog(@"%@", result);
    } :^(id result) {
        NSLog(@"%@", result);
    }];
}

- (NSArray<NSDictionary *> *)registerAdaptItemClass {
    return @[@{@"class":@"ICTestCell",
               @"id":@"1000"},
             @{@"class":@"ICTestCell1",
               @"id":@"1001"},
             @{@"class":@"ICKOrderTableViewCell",
               @"id":@"1009"}];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath select:(id)result {
    NSLog(@"%@",  result);
}

- (void)openNewsDetailFromViewC:(UIViewController *)fromViewC :(id)param {
    NSLog(@"%@", param);
}

//- (void)createGroupUsers:(void(^)(id))users {
//    // 打开通讯录
//    // 回调处理block
//    if (users) {
//        users(@[@{@"eId":@"10033226",@"eName":@"潘老总"}]);
//    }
//}

//- (void)createGroupDepartment:(void(^)(id result))department {//部门@[@{@"oId":@"xxxx",@"gName":@"xxxx"}]
//    if (department) {
//        department(@[@{@"oId":@"50268332",@"gName":@"该群组不要随意使用"}]);
//    }
//}

//- (void)appendGroupUsers:(void(^)(id result))users {//员工@[@{"eId":@"xxxx",@"eName":@"xxxx"},@{"eId":@"xxxx",@"eName":@"xxxx"}]
//    if (users) {
//        users(@[
//                @{@"eId":@"10033226",
//                  @"eName":@"潘老总"},
//                @{@"eId":@"10045247",
//                  @"eName":@"疆总"}
//                ]);
//    }
//}

- (void)openContactsDetailsFromViewC:(UIViewController *)fromViewC :(id)param {
    NSLog(@"%@", param);
}

//- (void)update {
//    NSLog(@"重新获取消息");
//    [self unreadCount];
//}

- (void)openWebViewNativeMethodsWithParams:(id)params :(UIViewController *)fromViewC :(SDKProtocolHandler)callBack {
    NSLog(@"%@", params);
    if ([params[@"method"] isEqualToString:@"showNews"]) {
        NSLog(@"带参数去打开新闻, 并且如果有callback时也必须把name回传");
    }
    
    if (callBack) {// 如果需要callback必须把对应的method回传
        callBack(@{@"method":@"showNews"});
    }
}


- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    //    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"Token"]) {
    //        UIViewController *viewController =[[IComMediator sharedInstance] IComMediator_MessageVController:nil];
    //        ICNavigationController *nav = [[ICNavigationController alloc] initWithRootViewController:viewController];
    //        [UIApplication sharedApplication].keyWindow.rootViewController = nav;
    //        [[ICDefaultConfigManager sharedInstance] createDefaultGroups];
    //        [[ICDefaultConfigManager fedInstance] initTCP];
    //    } else {
    //        ICLoginViewController *log = [[ICLoginViewController alloc] init];
    //        [self presentViewController:log animated:YES completion:^{
    //            NSLog(@"%@", @"成功");
    //        }];
    //    }
}

- (void)regiseriComeApi {
    [[iComeApiManager instance] regiserApiUserName:@"zhangrongwu" passWord:@"123" server:Server_DEBUG :^(id result) {
        NSString *Alias = result[@"Alias"];
        NSLog(@"成功%@ , %@", result, Alias);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        NSUserDefaults *token = [[NSUserDefaults standardUserDefaults] objectForKey:@"Token"];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)openChatList {
    [[iComeApiManager instance] openChatList:self :^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)createGroupWithName {
    [[iComeApiManager instance] createGroupWithgName:@"我是一个组名称" eIds:@[@"10070758",@"10068730", @"10070532"] fromViewC:self :^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)openChatWindow {
    
    [[iComeApiManager instance] openChatWindowWithgId:@"mlt_10000031" message:nil fromViewC:self :^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)openChatWindowWithMesssage{
    IMMessage *message = [[IMMessage alloc] init];
    message.txt = @"打开会话，并且发送一条消息";
    message.type = @"1009";
    message.data = @{@"key":@"参数",
                     @"key2":@"参数二"
                     };
    [[iComeApiManager instance] openChatWindowWithgId:@"mlt_10000399" message:message fromViewC:self :^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)shareToChat {
    IMMessage *message = [[IMMessage alloc] init];
    message.txt = @"分享";
    message.type = @"1";
    message.data = @{};
    [[iComeApiManager instance] shareToChatWithMessage:message fromViewC:self :^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)getEmpPhoto{
    NSString *url = [[iComeApiManager instance] getEmpPhoto:@"10045111"];
    NSLog(@"返回的用户头像url %@",url);
    ALERTSDK(url);
    
}

- (void)destroy {
    [[iComeApiManager instance] destroy:^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)openWebView {
    [[iComeApiManager instance] pushWebViewControllerURL:@"http://jsdemo-test.icome.enn.cn:8000"
                                               fromViewC:self
                                                animated:YES];
   // [[iComeApiManager instance] pushWebViewControllerURL:@"http://10.37.148.203:8081/meeting/ienmeetingcalendar?isapp=yes"
     //                                          fromViewC:self
       //                                         animated:YES];
}

- (void)unreadCount {
    [[iComeApiManager instance] msgGet:^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
        
    }];
}

- (void)getRrecentPersion {
    [[iComeApiManager instance] getRrecentPersion:^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)appendUsers {
    [[iComeApiManager instance] appendUsers:@"mlt_10000003" eIds:@[@"10070758",@"10068730", @"10070532"] :^(id result) {
        NSLog(@"成功%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    } :^(id result) {
        NSLog(@"失败%@", result);
        NSString *al = [NSString stringWithFormat:@"%@", result];
        ALERTSDK(al);
    }];
}

- (void)twoChat {
    
    [[iComeApiManager instance] openChatWith:@"10045244" fromViewC:self :^(id result) {
        NSLog(@"成功%@", result);
    } :^(id result) {
        NSLog(@"失败%@", result);
    }];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
